<template>
	<view style="">
		<!-- 最上面的搜索框 -->
		<view style="background-color: white;padding:20rpx;padding-bottom: 0;">
			<u-search inputAlign="center" placeholder="名称/客户/手机号/税号" @search="data=[];form.page=1;getData()"
				@click="data=[];getData()" v-model="form.text" :showAction="false"></u-search>
		</view>

		<!-- 卡片 -->
		<view style="">
			<view >
				
			</view>
			<scroll-view scroll-y style="height: calc(100vh - 240rpx);" @scrolltolower="scrolltolower"
				:refresher-enabled="true" :refresher-triggered="refresher" @refresherrefresh="refresherpulling">
				<view >
					<u-card padding="20" box-shadow="2rpx 2rpx 5rpx #EEEDED" v-for="item in data">
						<view slot="head" style="display: flex;justify-content: space-between;">
							<view style="font-weight: bold;color: #000;">
								<text v-if="item.fplx==1">数电普通发票</text>
								<text v-if="item.fplx==2">数电专用发票</text>
							</view>
							<view class="currency">{{item.je}}</view>
						</view>
						<view slot="body" style="width: 100%;">
							<view style="color: #909399;width: 100%;">
								<view>
									<text>税号：</text>
									<text>{{item.sh}}</text>
								</view>
					
								<view style="margin-top: 10rpx">
									<text>名称：</text>
									<text>{{item.mc}}</text>
								</view>
								<view style="margin-top: 10rpx">
									<text>客户姓名：</text>
									<text>{{item.khxm}}</text>
								</view>
								<view style="margin-top: 10rpx">
									<text>手机号：</text>
									<text>{{item.sjh}}</text>
								</view>
					
								<view style="margin-top: 10rpx">
									<text>申请单号：</text>
									<text>{{item.kpsq_num}}</text>
								</view>
					
								<view style="margin-top: 10rpx;display: flex;width: 100%;" v-if="item.orders.length>0">
									<text style="white-space: nowrap;">订单号：</text>
									<view style="width: 100%;display: flex;justify-content: space-between;">
										<text style="color: #2979ff;font-weight: bold;"
											@click="toOrdersInfoPage(item.orders[0].orders_id)">{{item.orders[0].orders_num}}</text>
										<text style="white-space: nowrap;"
											v-if="item.orders.length>1">等{{item.orders.length}}个订单</text>
									</view>
								</view>
								<view style="margin-top: 10rpx;display: flex;width: 100%;" v-if="item.invoiceInfoList.length>0">
									<text style="white-space: nowrap;">发票号：</text>
									<view style="width: 100%;display: flex;justify-content: space-between;">
										<text>
											{{item.invoiceInfoList[0].invoice_no}}
										</text>
										<text style="white-space: nowrap;"
											v-if="item.invoiceInfoList.length>1">等{{item.invoiceInfoList.length}}张发票</text>
									</view>
								</view>
							</view>
						</view>
						<view slot="foot">
							<view style="display: flex;justify-content: flex-end">
								<u-button type="primary" plain size="mini" @click="select(item)">选择</u-button>
							</view>
						</view>
					</u-card>
				</view>
			</scroll-view>

		</view>
	</view>
</template>

<script>
	import http from '../../http/http';

	export default {
		comments: {

		},
		data() {
			return {
				refresher: false,
				data: [],
				form: {
					page: 1,
					limit: 20,
					total: 0,
					text: ''
				},
				keyword: '',
			}
		},
		mounted() {
			this.getData();
			var that = this;
		},
		onLoad(options) {
			var that = this;
			if (options.deposit_pay_id) {
				this.deposit_pay_id = options.deposit_pay_id;
			}
		},
		methods: {
			select(kpsq){
				uni.$emit('selectKpsq',kpsq);
				uni.navigateBack();
			},
			refresherpulling() {
				this.form.page = 1;
				this.refresher = true;
				this.data = [];
				this.getData();
			},
			scrolltolower(e) {
				console.log(e);
				this.form.page++;
				this.getData();
			},
			getData() {
				var that = this;
				that.$http.post('/kpsq/ListByEntity', that.form, (res) => {
					if (res.data.success) {
						that.data = that.data.concat(res.data.result.list);
						that.form.total = res.data.result.count;
						that.refresher = false;
					} else {
						that.refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
		}
	}
</script>

<style>

</style>